package cn.tedu.ssm.mapper;

import cn.tedu.ssm.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.omg.CORBA.PUBLIC_MEMBER;

import java.util.List;

public interface UserMapper {

    @Select("select id ,`username`,`disabled` from `hbeu_user` where `deleted`=0 limit #{o},#{l}")
    public List<User> find(@Param("o") int offset, @Param("l") int limit);

    @Select("select count(1) from `hbeu_user` where deleted =0 ")
    public  Long count();

    @Select("select count(1) from `hbeu_user` where username=#{u} ")
    public boolean exists(@Param("u") String username);
    @Select("select count(1) from `hbeu_user` where id = #{id}")
    public boolean existsById(@Param("id") Long id);
    @Select("SELECT id FROM `hbeu_user` WHERE username = #{u} AND `password` = #{p}")
    public Long findIdByUsernameAndPassword(@Param("u") String username, @Param("p") String password);

    @Select("SELECT COUNT(1) FROM `hbeu_user` WHERE id = #{i} AND `deleted` = 1")
    public boolean isDeleted(@Param("i") Long id);

    // 4. 根据 ID 账号是否已经被禁用
    @Select("SELECT COUNT(1) FROM `hbeu_user` WHERE id = #{i} AND `disabled` = 1")
    public boolean isDisabled(@Param("i") Long id);

    @Select("select name from `hbeu_user` where id=#{i}")
    public User userInfo(@Param("i") Long id);
}

